/**
 * \class CChord
 * \brief This is a class to configure a chord toplogy which is one of DHT toplogies.
 * \version 0.3.2
 *
 * \author Woo-Hyun Kim (woorung@nhncorp.com, woorung@gmail.com)
 * \author http://blog.naver.com/wisereign .
 *
 * \date 2007/10/9
 */
#ifndef CChordH
#define CChordH
//-----------------------------------------------------------------
#include <iostream>
#include <vector>
#include <map>
#include <iterator>

#include "CDHT.h"

using namespace std;

class CChord : public CDHT
{
private:
	map<int,string> local_skeys;

protected:
	void init();
	void fin();

	int local_spaces(char *ip);

public:
        CChord();
        CChord(char *host, int port);
        virtual ~CChord();

	// lookup in local spaces
	virtual vector<CServiceInfo> &llookup(char *ip, vector<CServiceInfo> &ls);

	// lookup all in workspaces
	virtual vector<CServiceInfo> &lookup(vector<CServiceInfo> &ls);

	// lookup in distribued spaces
	virtual CServiceInfo &lookup(char *key);
	virtual CServiceInfo &predecessor(char *key);
	virtual CServiceInfo &successor(char *key);
};
//-----------------------------------------------------------------
#endif
